package com.vue.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vue.mapper.Order_DemoMapper;
import com.vue.pojo.Order_Demo;
import com.vue.service.Order_De_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
@Transactional
public class ImOrder_demo extends ServiceImpl<Order_DemoMapper,Order_Demo> implements Order_De_Service {
    @Autowired
    private Order_DemoMapper order_demoMapper;
    @Override
    public  Page<Order_Demo> findll(Integer pagenumber, Integer pagesize) {
        Page<Order_Demo> order_demoPage=new Page<>(pagenumber,pagesize);
        Page<Order_Demo> order_demoPage1 = order_demoMapper.selectPage(order_demoPage, null);
        return order_demoPage1;
    }

    @Override
    public int delOne(Integer id) {
        return order_demoMapper.deleteById(id);
    }

    @Override
    public Order_Demo findOne(Integer id) {
        return order_demoMapper.selectById(id);
    }

    @Override
    public int upOne(Order_Demo order_demo) {
        return order_demoMapper.updateById(order_demo);
    }

    @Override
    public Page<Order_Demo> findlll(Integer pagenumber, Integer pagesize, Integer id,String name) {
        QueryWrapper queryWrapper=new QueryWrapper();
        if(id!=null){
            queryWrapper.eq("userId",id);
        }
        if(!StringUtils.isEmpty(name)){
            queryWrapper.eq("orderStatus",name);
        }
        Page<Order_Demo> order_demoPage=new Page<>(pagenumber,pagesize);
        Page<Order_Demo> order_demoPage1 = order_demoMapper.selectPage(order_demoPage,queryWrapper);
        return order_demoPage1;
    }
}
